package com.gf.snoopy.util.page;

/**
 *
 */
public class Page {

    private static final Integer DEFAULT_PAGESIZE = 20;

    private static final Integer DEFAULT_OFFSET = 0;

    /**
     * 分页大小
     */
    private Integer pageSize;

    /**
     * 分页偏移
     */
    private Integer offset;

    /**
     * 总数据量
     */
    private Integer total;

    public static Page getPage(Integer pageSize,Integer pageNum){
        Page page = new Page();
        if(pageSize==null||pageNum==null||pageSize<=0||pageNum<1){
            page.setPageSize(DEFAULT_PAGESIZE);
            page.setOffset(DEFAULT_OFFSET);
            return page;
        }
        page.setPageSize(pageSize);
        page.setOffset((pageNum-1)*pageSize);
        return page;
    }

    public Integer getOffset() {
        return offset;
    }

    public void setOffset(Integer offset) {
        this.offset = offset;
    }

    public Integer getTotal() {
        return total;
    }

    public void setTotal(Integer total) {
        this.total = total;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }
}
